package org.ydeity.lucene.core;

import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.io.Serializable;
import java.util.List;
import java.util.Optional;

public interface LuceneOperations {

    <T> boolean doInsert(T t);

    <T> boolean doUpdate(T t);

    <T> int saveAll(Iterable<? extends T> iterable,Class<? extends T> clazz);

    <T> boolean doDelete(Class<? extends T> clazz, Serializable id);

    <T> boolean delete(T t);

    <T> long deleteAll(Class<T> clazz);

    <T> long deleteAll(Iterable<? extends T> iterable, Class<T> clazz);

    <T> long count(Class<? extends T> clazz,String field);

    <T> Optional<T> getById(Class<? extends T> clazz, Serializable id);

    <T> List<T> queryForObject(Class<? extends T> clazz, Query query, int n);

    <T> List<T> queryForObject(Class<? extends T> clazz, Query query, Sort sort, int n);

    <T> Page<T> search(Class<? extends T> clazz, Query query, Pageable pageable);

    <T> Page<T> search(Class<? extends T> clazz, Query query, Sort sort, Pageable pageable);
}
